//一般直接写在一个js文件中
layui.use(['element','form','laydate','upload','layer'],function () {
    //选择老人
    $("#elderlyName").on('click',function () {
        layer.open({
            type: 2,
            content: '/receipt/select/elderly',
            area: ['800px', '600px'],
            title:'选择老人',
            btn: ['确定 '],
            yes:function(index, layero){
                var iframeWin = window[layero.find('iframe')[0]['name']]; //得到iframe页的窗口对象
                var checkStatus = iframeWin.layui.table.checkStatus('mytable');
                if(checkStatus.data.length < 1 || checkStatus.data.length > 1){
                    iframeWin.layui.layer.msg("请选择一位老人");
                    return false;
                }
                var name = checkStatus.data[0].name;
                var id = checkStatus.data[0].id;
                var code = checkStatus.data[0].code;
                $("#elderlyName").val(name);
                $("#elderlyCode").val(code);
                layer.close(index);
            }
        });
    });

});